package cn.ibizlab.odoo.core.odoo_hr.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Ihr_applicant;
import cn.ibizlab.odoo.core.odoo_hr.domain.Hr_applicant;
import cn.ibizlab.odoo.core.odoo_hr.filter.Hr_applicantSearchContext;
import cn.ibizlab.odoo.core.odoo_hr.service.IHr_applicantService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[申请人] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Hr_applicantServiceImpl implements IHr_applicantService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Ihr_applicantClientService hr_applicantClientService;

    @Override
    public boolean create(Hr_applicant hr_applicant) {
        boolean bOk = false ;
        Ihr_applicant clientModel = this.convert2Model(hr_applicant,null);
        hr_applicantClientService.create(clientModel) ;
        this.convert2Domain(clientModel,hr_applicant);
        bOk = true ;

        return bOk ;
    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //hr_applicantClientService.removeBatch(hr_applicants) ;

    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Ihr_applicant clientModel = hr_applicantClientService.createModel();
        clientModel.setId(id);
        hr_applicantClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public void createBatch(List<Hr_applicant> hr_applicants, int batchSize) {

                        //hr_applicantClientService.createBatch(hr_applicants,batchSize) ;

    }

    @Override
    public boolean update(Hr_applicant hr_applicant) {
        boolean bOk = false ;
        Ihr_applicant clientModel = this.convert2Model(hr_applicant,null);
        hr_applicantClientService.update(clientModel) ;
        this.convert2Domain(clientModel,hr_applicant) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public void updateBatch(List<Hr_applicant> hr_applicants, int batchSize) {

        //hr_applicantClientService.updateBatch(hr_applicants,batchSize) ;

    }

    @Override
    public Hr_applicant get(Integer id) {
        Ihr_applicant clientModel = hr_applicantClientService.createModel();
        clientModel.setId(id);
        hr_applicantClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Hr_applicant get(Hr_applicant hr_applicant) {
        Hr_applicant rethr_applicant = this.get(hr_applicant.getId()) ;
    	BeanCopier copier=BeanCopier.create(rethr_applicant.getClass(), hr_applicant.getClass(), false);
        copier.copy(rethr_applicant, hr_applicant, null);
        return hr_applicant ;
    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Hr_applicant> searchDefault(Hr_applicantSearchContext context) {
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据HR 部门查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_department(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据员工查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_emp(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据工作岗位查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_job(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据申请人学历查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_type(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据招聘阶段查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_last_stage(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据招聘阶段查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_stage(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_company(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_partner(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_create(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_user(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_write(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据UTM 营销活动查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_campaign(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据UTM媒体查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_medium(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据UTM来源查询
     */
    @Override
    public Page<Hr_applicant> selectByOdoo_source(Integer id){
        Hr_applicantSearchContext context = new Hr_applicantSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_applicant> list = new ArrayList<Hr_applicant>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_applicant> clientModelList = hr_applicantClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_applicant clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_applicant>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Ihr_applicant convert2Model(Hr_applicant domain , Ihr_applicant model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = hr_applicantClientService.createModel() ;
        }

         if(domain.getPriorityDirtyFlag())
            model.setPriority(domain.getPriority());
         if(domain.getSalary_expectedDirtyFlag())
            model.setSalary_expected(domain.getSalary_expected());
         if(domain.getCateg_idsDirtyFlag())
            model.setCateg_ids(domain.getCateg_ids());
         if(domain.getMessage_has_errorDirtyFlag())
            model.setMessage_has_error(domain.getMessage_has_error());
         if(domain.getSalary_proposedDirtyFlag())
            model.setSalary_proposed(domain.getSalary_proposed());
         if(domain.getAttachment_numberDirtyFlag())
            model.setAttachment_number(domain.getAttachment_number());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getMessage_idsDirtyFlag())
            model.setMessage_ids(domain.getMessage_ids());
         if(domain.getDescriptionDirtyFlag())
            model.setDescription(domain.getDescription());
         if(domain.getPartner_phoneDirtyFlag())
            model.setPartner_phone(domain.getPartner_phone());
         if(domain.getMessage_needaction_counterDirtyFlag())
            model.setMessage_needaction_counter(domain.getMessage_needaction_counter());
         if(domain.getKanban_stateDirtyFlag())
            model.setKanban_state(domain.getKanban_state());
         if(domain.getMessage_needactionDirtyFlag())
            model.setMessage_needaction(domain.getMessage_needaction());
         if(domain.getActivity_type_idDirtyFlag())
            model.setActivity_type_id(domain.getActivity_type_id());
         if(domain.getDate_openDirtyFlag())
            model.setDate_open(domain.getDate_open());
         if(domain.getDay_openDirtyFlag())
            model.setDay_open(domain.getDay_open());
         if(domain.getMessage_main_attachment_idDirtyFlag())
            model.setMessage_main_attachment_id(domain.getMessage_main_attachment_id());
         if(domain.getActivity_stateDirtyFlag())
            model.setActivity_state(domain.getActivity_state());
         if(domain.getAvailabilityDirtyFlag())
            model.setAvailability(domain.getAvailability());
         if(domain.getSalary_expected_extraDirtyFlag())
            model.setSalary_expected_extra(domain.getSalary_expected_extra());
         if(domain.getDate_closedDirtyFlag())
            model.setDate_closed(domain.getDate_closed());
         if(domain.getMessage_unread_counterDirtyFlag())
            model.setMessage_unread_counter(domain.getMessage_unread_counter());
         if(domain.getMessage_is_followerDirtyFlag())
            model.setMessage_is_follower(domain.getMessage_is_follower());
         if(domain.getPartner_mobileDirtyFlag())
            model.setPartner_mobile(domain.getPartner_mobile());
         if(domain.getMessage_has_error_counterDirtyFlag())
            model.setMessage_has_error_counter(domain.getMessage_has_error_counter());
         if(domain.getSalary_proposed_extraDirtyFlag())
            model.setSalary_proposed_extra(domain.getSalary_proposed_extra());
         if(domain.getMessage_follower_idsDirtyFlag())
            model.setMessage_follower_ids(domain.getMessage_follower_ids());
         if(domain.getMessage_channel_idsDirtyFlag())
            model.setMessage_channel_ids(domain.getMessage_channel_ids());
         if(domain.getEmail_fromDirtyFlag())
            model.setEmail_from(domain.getEmail_from());
         if(domain.getWebsite_message_idsDirtyFlag())
            model.setWebsite_message_ids(domain.getWebsite_message_ids());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getMessage_partner_idsDirtyFlag())
            model.setMessage_partner_ids(domain.getMessage_partner_ids());
         if(domain.getDate_last_stage_updateDirtyFlag())
            model.setDate_last_stage_update(domain.getDate_last_stage_update());
         if(domain.getActivity_user_idDirtyFlag())
            model.setActivity_user_id(domain.getActivity_user_id());
         if(domain.getMessage_unreadDirtyFlag())
            model.setMessage_unread(domain.getMessage_unread());
         if(domain.getMessage_attachment_countDirtyFlag())
            model.setMessage_attachment_count(domain.getMessage_attachment_count());
         if(domain.getActivity_idsDirtyFlag())
            model.setActivity_ids(domain.getActivity_ids());
         if(domain.getActiveDirtyFlag())
            model.setActive(domain.getActive());
         if(domain.getReferenceDirtyFlag())
            model.setReference(domain.getReference());
         if(domain.getAttachment_idsDirtyFlag())
            model.setAttachment_ids(domain.getAttachment_ids());
         if(domain.getEmail_ccDirtyFlag())
            model.setEmail_cc(domain.getEmail_cc());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getPartner_nameDirtyFlag())
            model.setPartner_name(domain.getPartner_name());
         if(domain.getDay_closeDirtyFlag())
            model.setDay_close(domain.getDay_close());
         if(domain.getProbabilityDirtyFlag())
            model.setProbability(domain.getProbability());
         if(domain.getColorDirtyFlag())
            model.setColor(domain.getColor());
         if(domain.getActivity_summaryDirtyFlag())
            model.setActivity_summary(domain.getActivity_summary());
         if(domain.getDelay_closeDirtyFlag())
            model.setDelay_close(domain.getDelay_close());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getActivity_date_deadlineDirtyFlag())
            model.setActivity_date_deadline(domain.getActivity_date_deadline());
         if(domain.getSource_id_textDirtyFlag())
            model.setSource_id_text(domain.getSource_id_text());
         if(domain.getCampaign_id_textDirtyFlag())
            model.setCampaign_id_text(domain.getCampaign_id_text());
         if(domain.getDepartment_id_textDirtyFlag())
            model.setDepartment_id_text(domain.getDepartment_id_text());
         if(domain.getLast_stage_id_textDirtyFlag())
            model.setLast_stage_id_text(domain.getLast_stage_id_text());
         if(domain.getStage_id_textDirtyFlag())
            model.setStage_id_text(domain.getStage_id_text());
         if(domain.getMedium_id_textDirtyFlag())
            model.setMedium_id_text(domain.getMedium_id_text());
         if(domain.getLegend_normalDirtyFlag())
            model.setLegend_normal(domain.getLegend_normal());
         if(domain.getUser_id_textDirtyFlag())
            model.setUser_id_text(domain.getUser_id_text());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getType_id_textDirtyFlag())
            model.setType_id_text(domain.getType_id_text());
         if(domain.getJob_id_textDirtyFlag())
            model.setJob_id_text(domain.getJob_id_text());
         if(domain.getLegend_doneDirtyFlag())
            model.setLegend_done(domain.getLegend_done());
         if(domain.getLegend_blockedDirtyFlag())
            model.setLegend_blocked(domain.getLegend_blocked());
         if(domain.getEmployee_nameDirtyFlag())
            model.setEmployee_name(domain.getEmployee_name());
         if(domain.getUser_emailDirtyFlag())
            model.setUser_email(domain.getUser_email());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getPartner_id_textDirtyFlag())
            model.setPartner_id_text(domain.getPartner_id_text());
         if(domain.getCompany_id_textDirtyFlag())
            model.setCompany_id_text(domain.getCompany_id_text());
         if(domain.getJob_idDirtyFlag())
            model.setJob_id(domain.getJob_id());
         if(domain.getCampaign_idDirtyFlag())
            model.setCampaign_id(domain.getCampaign_id());
         if(domain.getLast_stage_idDirtyFlag())
            model.setLast_stage_id(domain.getLast_stage_id());
         if(domain.getDepartment_idDirtyFlag())
            model.setDepartment_id(domain.getDepartment_id());
         if(domain.getPartner_idDirtyFlag())
            model.setPartner_id(domain.getPartner_id());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getMedium_idDirtyFlag())
            model.setMedium_id(domain.getMedium_id());
         if(domain.getEmp_idDirtyFlag())
            model.setEmp_id(domain.getEmp_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getType_idDirtyFlag())
            model.setType_id(domain.getType_id());
         if(domain.getSource_idDirtyFlag())
            model.setSource_id(domain.getSource_id());
         if(domain.getStage_idDirtyFlag())
            model.setStage_id(domain.getStage_id());
         if(domain.getCompany_idDirtyFlag())
            model.setCompany_id(domain.getCompany_id());
         if(domain.getUser_idDirtyFlag())
            model.setUser_id(domain.getUser_id());
        return model ;
    }

    public Hr_applicant convert2Domain( Ihr_applicant model ,Hr_applicant domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Hr_applicant();
        }

        if(model.getPriorityDirtyFlag())
            domain.setPriority(model.getPriority());
        if(model.getSalary_expectedDirtyFlag())
            domain.setSalary_expected(model.getSalary_expected());
        if(model.getCateg_idsDirtyFlag())
            domain.setCateg_ids(model.getCateg_ids());
        if(model.getMessage_has_errorDirtyFlag())
            domain.setMessage_has_error(model.getMessage_has_error());
        if(model.getSalary_proposedDirtyFlag())
            domain.setSalary_proposed(model.getSalary_proposed());
        if(model.getAttachment_numberDirtyFlag())
            domain.setAttachment_number(model.getAttachment_number());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getMessage_idsDirtyFlag())
            domain.setMessage_ids(model.getMessage_ids());
        if(model.getDescriptionDirtyFlag())
            domain.setDescription(model.getDescription());
        if(model.getPartner_phoneDirtyFlag())
            domain.setPartner_phone(model.getPartner_phone());
        if(model.getMessage_needaction_counterDirtyFlag())
            domain.setMessage_needaction_counter(model.getMessage_needaction_counter());
        if(model.getKanban_stateDirtyFlag())
            domain.setKanban_state(model.getKanban_state());
        if(model.getMessage_needactionDirtyFlag())
            domain.setMessage_needaction(model.getMessage_needaction());
        if(model.getActivity_type_idDirtyFlag())
            domain.setActivity_type_id(model.getActivity_type_id());
        if(model.getDate_openDirtyFlag())
            domain.setDate_open(model.getDate_open());
        if(model.getDay_openDirtyFlag())
            domain.setDay_open(model.getDay_open());
        if(model.getMessage_main_attachment_idDirtyFlag())
            domain.setMessage_main_attachment_id(model.getMessage_main_attachment_id());
        if(model.getActivity_stateDirtyFlag())
            domain.setActivity_state(model.getActivity_state());
        if(model.getAvailabilityDirtyFlag())
            domain.setAvailability(model.getAvailability());
        if(model.getSalary_expected_extraDirtyFlag())
            domain.setSalary_expected_extra(model.getSalary_expected_extra());
        if(model.getDate_closedDirtyFlag())
            domain.setDate_closed(model.getDate_closed());
        if(model.getMessage_unread_counterDirtyFlag())
            domain.setMessage_unread_counter(model.getMessage_unread_counter());
        if(model.getMessage_is_followerDirtyFlag())
            domain.setMessage_is_follower(model.getMessage_is_follower());
        if(model.getPartner_mobileDirtyFlag())
            domain.setPartner_mobile(model.getPartner_mobile());
        if(model.getMessage_has_error_counterDirtyFlag())
            domain.setMessage_has_error_counter(model.getMessage_has_error_counter());
        if(model.getSalary_proposed_extraDirtyFlag())
            domain.setSalary_proposed_extra(model.getSalary_proposed_extra());
        if(model.getMessage_follower_idsDirtyFlag())
            domain.setMessage_follower_ids(model.getMessage_follower_ids());
        if(model.getMessage_channel_idsDirtyFlag())
            domain.setMessage_channel_ids(model.getMessage_channel_ids());
        if(model.getEmail_fromDirtyFlag())
            domain.setEmail_from(model.getEmail_from());
        if(model.getWebsite_message_idsDirtyFlag())
            domain.setWebsite_message_ids(model.getWebsite_message_ids());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getMessage_partner_idsDirtyFlag())
            domain.setMessage_partner_ids(model.getMessage_partner_ids());
        if(model.getDate_last_stage_updateDirtyFlag())
            domain.setDate_last_stage_update(model.getDate_last_stage_update());
        if(model.getActivity_user_idDirtyFlag())
            domain.setActivity_user_id(model.getActivity_user_id());
        if(model.getMessage_unreadDirtyFlag())
            domain.setMessage_unread(model.getMessage_unread());
        if(model.getMessage_attachment_countDirtyFlag())
            domain.setMessage_attachment_count(model.getMessage_attachment_count());
        if(model.getActivity_idsDirtyFlag())
            domain.setActivity_ids(model.getActivity_ids());
        if(model.getActiveDirtyFlag())
            domain.setActive(model.getActive());
        if(model.getReferenceDirtyFlag())
            domain.setReference(model.getReference());
        if(model.getAttachment_idsDirtyFlag())
            domain.setAttachment_ids(model.getAttachment_ids());
        if(model.getEmail_ccDirtyFlag())
            domain.setEmail_cc(model.getEmail_cc());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getPartner_nameDirtyFlag())
            domain.setPartner_name(model.getPartner_name());
        if(model.getDay_closeDirtyFlag())
            domain.setDay_close(model.getDay_close());
        if(model.getProbabilityDirtyFlag())
            domain.setProbability(model.getProbability());
        if(model.getColorDirtyFlag())
            domain.setColor(model.getColor());
        if(model.getActivity_summaryDirtyFlag())
            domain.setActivity_summary(model.getActivity_summary());
        if(model.getDelay_closeDirtyFlag())
            domain.setDelay_close(model.getDelay_close());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getActivity_date_deadlineDirtyFlag())
            domain.setActivity_date_deadline(model.getActivity_date_deadline());
        if(model.getSource_id_textDirtyFlag())
            domain.setSource_id_text(model.getSource_id_text());
        if(model.getCampaign_id_textDirtyFlag())
            domain.setCampaign_id_text(model.getCampaign_id_text());
        if(model.getDepartment_id_textDirtyFlag())
            domain.setDepartment_id_text(model.getDepartment_id_text());
        if(model.getLast_stage_id_textDirtyFlag())
            domain.setLast_stage_id_text(model.getLast_stage_id_text());
        if(model.getStage_id_textDirtyFlag())
            domain.setStage_id_text(model.getStage_id_text());
        if(model.getMedium_id_textDirtyFlag())
            domain.setMedium_id_text(model.getMedium_id_text());
        if(model.getLegend_normalDirtyFlag())
            domain.setLegend_normal(model.getLegend_normal());
        if(model.getUser_id_textDirtyFlag())
            domain.setUser_id_text(model.getUser_id_text());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getType_id_textDirtyFlag())
            domain.setType_id_text(model.getType_id_text());
        if(model.getJob_id_textDirtyFlag())
            domain.setJob_id_text(model.getJob_id_text());
        if(model.getLegend_doneDirtyFlag())
            domain.setLegend_done(model.getLegend_done());
        if(model.getLegend_blockedDirtyFlag())
            domain.setLegend_blocked(model.getLegend_blocked());
        if(model.getEmployee_nameDirtyFlag())
            domain.setEmployee_name(model.getEmployee_name());
        if(model.getUser_emailDirtyFlag())
            domain.setUser_email(model.getUser_email());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getPartner_id_textDirtyFlag())
            domain.setPartner_id_text(model.getPartner_id_text());
        if(model.getCompany_id_textDirtyFlag())
            domain.setCompany_id_text(model.getCompany_id_text());
        if(model.getJob_idDirtyFlag())
            domain.setJob_id(model.getJob_id());
        if(model.getCampaign_idDirtyFlag())
            domain.setCampaign_id(model.getCampaign_id());
        if(model.getLast_stage_idDirtyFlag())
            domain.setLast_stage_id(model.getLast_stage_id());
        if(model.getDepartment_idDirtyFlag())
            domain.setDepartment_id(model.getDepartment_id());
        if(model.getPartner_idDirtyFlag())
            domain.setPartner_id(model.getPartner_id());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getMedium_idDirtyFlag())
            domain.setMedium_id(model.getMedium_id());
        if(model.getEmp_idDirtyFlag())
            domain.setEmp_id(model.getEmp_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getType_idDirtyFlag())
            domain.setType_id(model.getType_id());
        if(model.getSource_idDirtyFlag())
            domain.setSource_id(model.getSource_id());
        if(model.getStage_idDirtyFlag())
            domain.setStage_id(model.getStage_id());
        if(model.getCompany_idDirtyFlag())
            domain.setCompany_id(model.getCompany_id());
        if(model.getUser_idDirtyFlag())
            domain.setUser_id(model.getUser_id());
        return domain ;
    }


}
